/**
 * 
 */
package com.axt.dbaudit.action.cfg;

import java.util.List;
import org.apache.struts2.json.annotations.JSON;

import com.axt.dbaudit.bean.cfg.MonitorBean;
import com.axt.dbaudit.model.cfg.DiskMonitor;
import com.axt.dbaudit.model.cfg.Monitor;
import com.axt.soa.action.BaseAction;
import com.axt.soa.msg.types.MsgParam;

/**
 * @author wangyl
 * 
 */
public class MonitorAction extends BaseAction {
	private MonitorBean monitorBean = new MonitorBean();
	private List<Monitor> monitors = null;
	private List<DiskMonitor> diskMonitors = null;

	@JSON(name = "monitors")
	public List<Monitor> getMonitors() {
		return monitors;
	}

	public void setMonitors(List<Monitor> monitors) {
		this.monitors = monitors;
	}

	@JSON(name = "diskmonitor")
	public List<DiskMonitor> getDiskMonitors() {
		return diskMonitors;
	}

	public void setDiskMonitor(List<DiskMonitor> diskMonitors) {
		this.diskMonitors = diskMonitors;
	}

	@JSON(name = "errcode")
	public int getErrcode() {
		return errcode;
	}

	@JSON(name = "errinfo")
	public String getErrinfo() {
		return errinfo;
	}

	private String system_type;
	private String memory_total;
	private String memory_free;
	private String use_cpu;
	private String symbol;
	private String disk_type;
	private String total;
	private String free;

	/**
	 * @return the system_type
	 */
	public String getSystem_type() {
		return system_type;
	}

	/**
	 * @param system_type
	 *            the system_type to set
	 */
	public void setSystem_type(String system_type) {
		this.system_type = system_type;
	}

	/**
	 * @return the memory_total
	 */
	public String getMemory_total() {
		return memory_total;
	}

	/**
	 * @param memory_total
	 *            the memory_total to set
	 */
	public void setMemory_total(String memory_total) {
		this.memory_total = memory_total;
	}

	/**
	 * @return the memory_free
	 */
	public String getMemory_free() {
		return memory_free;
	}

	/**
	 * @param memory_free
	 *            the memory_free to set
	 */
	public void setMemory_free(String memory_free) {
		this.memory_free = memory_free;
	}

	/**
	 * @return the use_cpu
	 */
	public String getUse_cpu() {
		return use_cpu;
	}

	/**
	 * @param use_cpu
	 *            the use_cpu to set
	 */
	public void setUse_cpu(String use_cpu) {
		this.use_cpu = use_cpu;
	}

	/**
	 * @return the symbol
	 */
	public String getSymbol() {
		return symbol;
	}

	/**
	 * @param symbol
	 *            the symbol to set
	 */
	public void setSymbol(String symbol) {
		this.symbol = symbol;
	}

	/**
	 * @return the disk_type
	 */
	public String getDisk_type() {
		return disk_type;
	}

	/**
	 * @param disk_type
	 *            the disk_type to set
	 */
	public void setDisk_type(String disk_type) {
		this.disk_type = disk_type;
	}

	/**
	 * @return the total
	 */
	public String getTotal() {
		return total;
	}

	/**
	 * @param total
	 *            the total to set
	 */
	public void setTotal(String total) {
		this.total = total;
	}

	/**
	 * @return the free
	 */
	public String getFree() {
		return free;
	}

	/**
	 * @param free
	 *            the free to set
	 */
	public void setFree(String free) {
		this.free = free;
	}

	/**
	 * 查询硬盘信息
	 */
	public String queryHDDInfo() {
		setDiskMonitor(monitorBean.queryDiskInfo(serverPath));
		setErrcode(monitorBean.getErrcode());
		setErrinfo(monitorBean.getErrinfo());

		return MsgParam.SUCCESS;
	}

	/**
	 * 查询内存与CPU信息
	 */
	public String queryMemAndCPU() {
		setMonitors(monitorBean.queryMemAndCPU(serverPath));
		setErrcode(monitorBean.getErrcode());
		setErrinfo(monitorBean.getErrinfo());

		return MsgParam.SUCCESS;

	}
}
